package L1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class _056 {
    /**
     * 猜数字
     */
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.valueOf(reader.readLine());
        Map<String,Integer> map = new HashMap<>();
        int sum=0;
        for(int i=0;i<N;i++){
            String[] s = reader.readLine().split(" ");
            map.put(s[0],Integer.valueOf(s[1]));
            sum+=Integer.valueOf(s[1]);
        }
        sum=sum/2/N;
        int min = 100;
        String name = "";
        for (String s:map.keySet()){
            Integer n = map.get(s);
            int temp = Math.abs((n-sum));
            if (temp<min){
                min=temp;
                name = s;
            }
        }
        System.out.println(sum+" "+name);

    }
}
